const app = getApp()
Component({   
	properties: {        
		background: { // 背景颜色            
			type: String,        
			value: 'linear-gradient(120deg,#F58745 0%,#F56545 100%)'     
		},        
		color: { // 字体颜色           
			type: String,            
			value: 'rgba(255, 255, 255, 1)'        
		},        
		navbarData: { // 头部数据          
			type: Object,  
			value: {},  
			observer: function(newVal, oldVal) {}      
		},      
		fontSize: { // 字体大小           
			type: Number,            
			value: 18       
		}, 
	},   
	// 组件创建时执行 
	attached: function(){          
		this.setStyle();    
	},    
	data: {
		statusBarHeight: app.globalData.statusBarHeight, // 头部高度
		height: app.globalData.height // 通知栏的高度
	},    
	methods: {      
		// 设置头部样式   
		setStyle: function() {            
			var that  = this                
			, containerStyle                
			, textStyle               
			containerStyle = ['background:' + that.data.background].join(';');            
			textStyle = ['color:' + that.data.color, 'font-size:' + that.data.fontSize + 'px'].join(';');                      
			that.setData({               
				containerStyle: containerStyle,                
				textStyle: textStyle,             
			})        
		},        
		// 返回事件        
		back: function(){  
			let pages = getCurrentPages();
			if (pages.length === 1) {
				wx.reLaunch({
					url: '/pages/index/index',
				})
			} else {
				this.triggerEvent('onback',{},{})
				wx.navigateBack()

			}       
		}, 
	}
})